local ClientOHOH = _G.ClientOHOH;

local M = ClientOHOH.class.new(script,ClientOHOH.files.OHOHOLYBUIBase());

local CallBackManager = ClientOHOH.load.CallBackManager();
local ItemTool = _G.CommonOHOH.load.ItemTool();
local HomeGui=ClientOHOH.load.UIManager().HomeGui

local LanguageHelper=_G.LanguageHelper 
local BigNumberHelper = ClientOHOH.load.BigNumberHelper();

function InitInsts(ui)
    ui.insts = {};
    ui.insts.BoostNew = "ctrl.boost.new"
    ui.insts.BoostOld = "ctrl.boost.old"
    ui.insts.BtnRebirth = "ctrl.btn.rebirth"
    -- ui.insts.BtnSkip = "ctrl.btn.skip"

    ui.insts.BtnSkip = "ctrl.btn.auto"


    ui.insts.LevelNew = "ctrl.level.new"
    ui.insts.LevelOld = "ctrl.level.old"
    -- ui.insts.ProgressClip = "ctrl.progress.clipping"
    -- ui.insts.ProgressNum = "ctrl.progress.num"
    -- ui.insts.ProgressIcon = "ctrl.progress.icon"
    ui.insts.TitleNew = "ctrl.title.new"
    ui.insts.TitleOld = "ctrl.title.old"
    ui.insts.RebirthNum = "ctrl.rebornNum"
    -- ui.insts.CloseIcon = "ctrl.switch"
    ui.insts.CloseIcon = "ctrl.colse"

    ui.insts.AutoState = "ctrl.btn.autoText"

end

function M.new(...)
    return M(...);
end

function M.ctor(self)
    InitInsts(self)

    M.super.ctor(self,ClientOHOH:GetPath_Loop("ReplicatedStorage.Resource.UI.RebirthGuiNew"))

    --关闭
    CallBackManager:AddRbxConnect(self,self.insts.CloseIcon.Activated,function()
        self:Hide()
    end)

end



function M.UpdateUI(self,rebirth,titleOldId,boostOldValue,TitleNewID,BoostNewValue)
    self.insts.RebirthNum.Text = rebirth
    self.insts.TitleOld.Text = LanguageHelper:GetText(titleOldId)
    self.insts.BoostOld.Text = BigNumberHelper:ToString(boostOldValue*100).. " %"
    -- self.insts.TitleOld.Text = LanguageHelper:GetText(Rebirth_Cfg[self.rebirth]["titleId"])

    -- if self.rebirth+2 > #Rebirth_Cfg then
    --     return 
    -- end
    self.insts.TitleNew.Text = LanguageHelper:GetText(TitleNewID)
    self.insts.BoostNew.Text = BigNumberHelper:ToString(BoostNewValue*100) .. " %"

end


function M.SetMax(self,rebirth,t1,b1,t2,b2,lv1,lv2)
    rebirth= rebirth or 0
    t1=t1 or "Max Rebirth"
    b1= b1 or 0.1
    t2= t2 or "???"
    b2= b2 or 0
    lv1=lv1 or "???"
    lv2=lv2 or "???"

    self.insts.RebirthNum.Text = rebirth
    self.insts.TitleOld.Text =t1
    self.insts.BoostOld.Text =BigNumberHelper:ToString(b1*100).. " %"

    self.insts.TitleNew.Text = t2
    self.insts.BoostNew.Text = b2 .. " %"
    
    self.insts.LevelOld.Text = lv1
    self.insts.LevelNew.Text =lv2

end


function M.SetNextMax(self)


end


function M.UpdateProgressUI(self,costItemAmount,hasItemAmount,image)



    -- local ratio = hasItemAmount/costItemAmount;
    -- if ratio>1 then
    --     ratio = 1
    -- end

    -- self.insts.ProgressNum.Text = BigNumberHelper:ToString(hasItemAmount).."/"..BigNumberHelper:ToString(costItemAmount);
    -- self.insts.ProgressIcon.Image =image
    -- self.insts.ProgressClip.Size = UDim2.new(ratio,0,1,0)
end


function M.UpdateLevelUI(self,requiredLevel,afterCsumLevel,currentLevel)

    if currentLevel <= requiredLevel then
        self.insts.LevelOld.Text = "level "..requiredLevel
        self.insts.LevelNew.Text = "level "..afterCsumLevel
        return
    end

    self.insts.LevelOld.Text = "level "..currentLevel
    self.insts.LevelNew.Text = "level "..afterCsumLevel
end



function M.SetAutoSate(self,isAuto)
    self.insts.AutoState.Text = isAuto
end


function M.dtor(self)
    M.super.dtor(self);
end

return M